#include <iostream>
#include <string>

template <typename T>
class Singleton {
public:
    template <typename... Args>
    static T& getInstance(Args&&... args) {
        static T instance(std::forward<Args>(args)...);
        return instance;
    }

    Singleton(const Singleton&) = delete;
    Singleton& operator=(const Singleton&) = delete;
private:
    Singleton() {}
    ~Singleton() {}
};

class NetworkConfig {
public:
    NetworkConfig(const std::string& ip, int port) {
        std::cout << "Constructor: " << ip << ":" << port << std::endl;
    }

    NetworkConfig(int port) {
        std::cout << "Constructor: Port=" << port << std::endl;
    }
};

int main() {
    NetworkConfig& config1 = Singleton<NetworkConfig>::getInstance("192.168.1.1", 8080);
    NetworkConfig& config2 = Singleton<NetworkConfig>::getInstance("192.168.1.2", 10000);
    NetworkConfig& config3 = Singleton<NetworkConfig>::getInstance(8080);
    std::cout << "Address of config1: " << &config1 << std::endl;
    std::cout << "Address of config2: " << &config2 << std::endl;
    std::cout << "Address of config2: " << &config3 << std::endl;
}

